package com.jeesite.modules.common;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;



public class OrderIdUtils {
    public static final String FORMAT_FULLTIME = "yyMMddHHmmssSSS";

    private static long orderNum = 0l;
    private static String date ;

    public static synchronized String getOrderNo() {
        String str = new SimpleDateFormat(FORMAT_FULLTIME).format(new Date());
        if(date==null||!date.equals(str)){
            date = str;
            orderNum  = 0l;
        }
        orderNum ++;
        long orderNo = Long.parseLong((date)) * 10000;
        orderNo += orderNum;
        return orderNo+"";
    }

    public static synchronized String getgameCardNo() {
        String str = new SimpleDateFormat(FORMAT_FULLTIME).format(new Date());
        if(date==null||!date.equals(str)){
            date = str;
            orderNum  = 0l;
        }
        orderNum ++;
        long orderNo = Long.parseLong((date)) * 100;
        orderNo += orderNum;
        return orderNo+"";
    }

    public static  synchronized  String getoken(){
        UUID uuid = UUID.randomUUID();
        return uuid.toString().replace("-","");
    }

    public static void main(String[] args) {
        System.out.println(getOrderNo());
    }

}
